﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using TRPOP.CRM.Component;
using TRPOP.CRM.Component.Common;
using TRPOP.Common;
using TRPOP.CRM.Component.Business;

namespace TRPOP.CRM.Web
{
    public partial class login : BaseAdmin
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (base.CheckLogin())
            {
                Redirect("Default.aspx");
            }
        }
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            //页面必填验证
            string strMSG = "用户名、密码或验证码";
            if (!PageAssist.CheckForm(txtLoginName, ref strMSG) || !PageAssist.CheckForm(txtPwd, ref strMSG) || !PageAssist.CheckForm(Secode, ref strMSG))
            {
                AlertDialog(strMSG);
                return;
            }

            if (Session["CheckCode"] == null)
            {
                AlertDialog("您可能长时间未操作，请重新输入验证码！");
                return;
            }
            if (Session["CheckCode"].ToString().ToLower() != Secode.Text.Trim().ToLower())
            {
                AlertDialog("验证码错误！");
                return;
            }

            //登录验证
            if (base.EmployeeLogin(txtLoginName.Text, txtPwd.Text))
            {
                CompanyManage.UpdateRemindCompany();
                //转向
                Redirect("Default.aspx");
            }
            else
            {
                Alert("您输入的用户名或密码错误！");
            }
        }
    }
}